package com.webdev.newtech.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.webdev.newtech.domain.SysUser;
import com.webdev.newtech.domain.TlCat;
import com.webdev.newtech.service.ITlCatService;
import com.webdev.newtech.utils.AjaxResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("tlcat")
public class TlCatController {
    @Resource
    ITlCatService catService;
    @GetMapping("list")
    public AjaxResult list(Integer pageNum,Integer pageSize,TlCat cat){
        System.out.println("获取列表");
        PageHelper.startPage(pageNum,pageSize);
        List<TlCat> list = catService.getList(cat);
        PageInfo info = new PageInfo<TlCat>(list);
        return AjaxResult.success(info);
    }
    @GetMapping("add")
    public AjaxResult add(TlCat cat){
        System.out.println("新增");
        return AjaxResult.success(catService.add(cat));
    }
    @GetMapping("update")
    public AjaxResult update(TlCat cat){
        System.out.println("更新");
        return AjaxResult.success(catService.update(cat));
    }
    @GetMapping("remove")
    public AjaxResult list(Integer id){
        System.out.println("根据id删除");
        return AjaxResult.success(catService.remove(id));
    }
}
